// pages/yijian/yijian.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
      tupian:[]
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      
  },
  shangc: function (e) {
      var that = this
      wx.chooseImage({
          count: 9, // 默认9
          sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
          sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
          success: function (res) {

              // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
              var tempFilePaths = res.tempFilePaths
              var tupian = that.data.tupian
              tupian.push(tempFilePaths)
              //   console.log(tupian)
              that.setData({
                  tupian: tupian
              })
          }
      })
  },
  formBindsubmit:function(e){
        console.log(e.detail.value.texta);
        console.log(e.detail.value.tel);
      console.log(this.data.tupian)
      var that = this
      wx.request({
          url: 'https://www.mayizhihuan.com/Home/My/opinion/',
          data: {
              opinions: e.detail.value.texta,
              phone: e.detail.value.tel,
              image:this.data.tupian,
              PHPSESSID: wx.getStorageSync('sid')
          },
          method: 'POST',
          header: {
              'content-type': 'application/x-www-form-urlencoded'   
          },
          success: function (res) {
              console.log(res.data)
              if (res.data) {
                wx.showToast({
                    title: '提交成功',
                    icon: 'success',
                    duration: 2000
                })
                setTimeout(function () {
                    wx.switchTab({
                        url: '../user/user'
                    })
                }, 1000);
            }
          }
      })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})